package com.css.zfzx.fwsjcj.modules.statistics.user.controller;

import com.css.zfzx.fwsjcj.commen.util.EasyPoiExcelUtil;
import com.css.zfzx.fwsjcj.modules.statistics.user.service.UserService;
import com.css.zfzx.fwsjcj.modules.statistics.user.vo.DivisionUserVo;
import com.css.zfzx.fwsjcj.modules.statistics.user.vo.UserNumVo;
import com.css.zfzx.fwsjcj.modules.statistics.user.vo.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 统计各个省市区用户数量
 * 统计每个用户
 *
 * @Author leon
 * @Date: 2021/6/28 1:58 下午
 */
@RestController
@RequestMapping("/fw/userinfo")
@Slf4j
public class UserInfoController {
    @Autowired
    private UserService userService;

    /**
     * 统计每个用户
     *
     * @param response
     */
    @GetMapping("/all")
    public void getUSer(HttpServletResponse response) {
        List<UserVo> userList = userService.getUserList();
        EasyPoiExcelUtil.exportExcel(userList, "房屋用户信息统计", "房屋用户信息统计", UserVo.class, "房屋用户信息统计.xls", response);
        log.info("导出成功");
    }

    /**
     * 统计各个省市区用户数量
     *
     * @param response
     */
    @GetMapping("/allnum")
    public void getUSerNum(HttpServletResponse response) {
        List<UserNumVo> userList = userService.getUserNumList();
        EasyPoiExcelUtil.exportExcel(userList, "房屋用户数量信息统计", "房屋用户数量信息统计", UserNumVo.class, "房屋用户数量信息统计.xls", response);
        log.info("导出成功");
    }


    /**
     * 统计省级注册的用户
     *
     * @param response
     */
    @GetMapping("/getProvinceUser")
    public void getProvinceUser(HttpServletResponse response) {
        List<DivisionUserVo> userList = userService.getProvinceUser();
        EasyPoiExcelUtil.exportExcel(userList, "各省注册人数统计", "各省注册人数统计", DivisionUserVo.class, "各省注册人数统计.xls", response);
        log.info("导出成功");
    }
}
